import java.util.Random;
import java.util.Scanner;

public class TestDemo {
    public static void main(String[] args) {

    }
    //求两个数字的最大值
    public static void main10(String[] args) {
        int a=10;
        int b=20;
        System.out.println(Math.max(a,b));

        //求绝对值
        System.out.println(Math.abs(a-b));
    }
    //输出1-100所有的素数
    public static void main9(String[] args) {
        for(int k=1;k<=100;k++){
            int i=2;
            for (i=2;i<Math.sqrt(k);i++){
                if(k%i==0){
                    break;
                }
            }
            if(i>Math.sqrt(k)){
                System.out.println(k);
            }
        }
    }
    //判断一个数是否是素数
    public static void main8(String[] args) {
        int n=7;
        int i=2;
        for (i=2;i<Math.sqrt(n);i++){
            if(n%i==0){
                break;
            }
        }
        if(i>Math.sqrt(n)){
            System.out.println(n);
        }
    }
    //猜数字游戏
    public static void main7(String[] args) {
        Scanner scanner=new Scanner(System.in);
                                //种子:每次生成的随机数都一样
       // Random random=new Random(888);
        Random random=new Random();
        int num= random.nextInt(100);//[0-100)
        System.out.println(num);
        while(true){
            System.out.println("请你输入你要猜的数字:");
            int n=scanner.nextInt();
            if(n>num){
                System.out.println("n>num");
            } else if (n==num) {
                System.out.println("n==num");
                break;
            }else{
                System.out.println("n<num");
            }
        }
    }
    //循环输入
    public static void main6(String[] args) {
       Scanner scanner=new Scanner(System.in);
        while(scanner.hasNextInt()){//下一个是否是整型
        int a=scanner.nextInt();
            System.out.println(a);
    }
    }
    public static void main5(String[] args) {
    //for循环
        int i;
        for (i=1;i<=10;i++){
            System.out.println(i);
        }

    }
    public static void main4(String[] args) {
        int i=1;
        while(i<=10){
            if(i == 3){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }
    public static void main3(String[] args) {
        int a=1;
        switch (a){
            case 1:
                System.out.println(1);
                break;
            case 2:
                System.out.println(2);
                break;
            default:
                System.out.println(3);

        }

    }
    public static void main2(String[] args) {
        //判断一个数是奇数还是偶数
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        if(a%2==0) {
            System.out.println("偶数");
        } else {
            System.out.println("奇数");
        }
    }
    public static void main1(String[] args) {
        short a=128;
        byte b=(byte)a;
        System.out.println(a);
        System.out.println(b);
        int a1=111;
        int a2=222;
        int a3=333;
        System.out.println(a1);
        System.out.println(a2);
        System.out.println(a3);
    }
}
